import type { RouteRecordRaw } from 'vue-router'
import { createRouter, createWebHistory } from 'vue-router'

import HelloView from '@/views/HelloView.vue'
import HomeView from '@/views/HomeView.vue'
import WelcomePage from '@/components/UserWelcomePage.vue'
import QuestionBank from '@/components/UserQuestionBank.vue'
import AccountPage from '@/components/UserAccountPage.vue'
import AdminLogin from '@/components/AdminLogin.vue'
import AdminView from '@/views/AdminView.vue'
import AdminUserPage from '@/components/AdminUserPage.vue'
import AdminKeysPage from '@/components/AdminKeysPage.vue'
import AdminAddPage from '@/components/AdminAddPage.vue'
import AdminVersionPage from '@/components/AdminVersionPage.vue'
import AdminQuestionPage from '@/components/AdminQuestionPage.vue'

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'hello',
    component: HelloView,
  },
  {
    path: '/home',
    name: 'home',
    component: HomeView,
    children: [
      {
        path: '',
        name: 'welcome',
        component: WelcomePage,
      },
      {
        path: 'welcome',
        name: 'welcome-page',
        component: WelcomePage,
      },
      {
        path: 'question',
        name: 'question',
        component: QuestionBank,
      },
      {
        path: 'account',
        name: 'account',
        component: AccountPage,
      },
    ],
  },
  {
    path: '/m',
    name: 'm',
    component: AdminView,
    children: [
      {
        path: '',
        name: 'AdminLoginRoot',
        component: AdminLogin,
      },
      {
        path: 'login',
        name: 'AdminLogin',
        component: AdminLogin,
      },
      {
        path: 'AdminUser',
        name: 'AdminUser',
        component: AdminUserPage,
      },
      {
        path: 'AdminKeys',
        name: 'AdminKeys',
        component: AdminKeysPage,
      },
      {
        path: 'AdminAdd',
        name: 'AdminAdd',
        component: AdminAddPage,
      },
      {
        path: 'AdminVersion',
        name: 'AdminVersion',
        component: AdminVersionPage,
      },
      {
        path: 'AdminQuestion',
        name: 'AdminQuestion',
        component: AdminQuestionPage,
      },
    ],
  },
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes,
})

export default router
